package 逆序对的数量;

import java.util.Scanner;


public class Main {
    static int N = 100010, n;
    static int[] q = new int[N];
    static int[] tmp = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            q[i] = in.nextInt();
        }
        System.out.println(q_sort(0, n - 1));
    }

    private static long q_sort(int l, int r) {
        if (l >= r) {
            return 0;
        }
        int mid = l + r >> 1;
        long ret = q_sort(l, mid) + q_sort(mid + 1, r);
        int k = 0, i = l, j = mid + 1;
        while (i <= mid && j <= r) {
            if (q[i] <= q[j]) {
                tmp[k++] = q[i++];
            } else {
                ret += mid - i + 1;
                tmp[k++] = q[j++];
            }
        }
        while (i <= mid) {
            tmp[k++] = q[i++];
        }
        while (j <= r) {
            tmp[k++] = q[j++];
        }
        for (int m = 0; m < r - l + 1; m++) {
            q[l + m] = tmp[m];
        }
        return ret;
    }
}
